package main

import (
	"fmt"
	"log"
	"os"

	"github.com/louloulin/dataflare/pkg/workflow"
)

func main() {
	// Parse workflow definition
	workflowPath := "examples/csv-workflow.yaml"
	if len(os.Args) > 1 {
		workflowPath = os.Args[1]
	}

	fmt.Printf("Parsing workflow: %s\n", workflowPath)

	definition, err := workflow.ParseFromFile(workflowPath)
	if err != nil {
		log.Fatalf("Failed to parse workflow: %v", err)
	}

	fmt.Printf("Parsed workflow: %s (%s)\n", definition.Name, definition.Description)
	fmt.Printf("Version: %s\n", definition.Version)
	
	fmt.Println("\nSources:")
	for id, source := range definition.Sources {
		fmt.Printf("  %s: type=%s\n", id, source.Type)
	}
	
	fmt.Println("\nProcessors:")
	for id, processor := range definition.Processors {
		fmt.Printf("  %s: type=%s\n", id, processor.Type)
	}
	
	fmt.Println("\nSinks:")
	for id, sink := range definition.Sinks {
		fmt.Printf("  %s: type=%s\n", id, sink.Type)
	}
	
	fmt.Println("\nEdges:")
	for i, edge := range definition.Edges {
		fmt.Printf("  %d: %s -> %s\n", i, edge.From, edge.To)
	}
	
	fmt.Println("\nWorkflow parsed successfully!")
}
